import { useRequest } from 'umi';

export type getLikePropType = {
  field: string;
  key: string;
  level: string;
};

export default function useGetLike(prop: getLikePropType) {
  const countryType = useRequest(
    () => {
      return {
        url: 'http://10.1.40.84:9993/getLike',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data: { ...prop, field: 'country' },
      };
    },
    {
      manual: true,
    },
  );

  const country = useRequest(
    () => {
      return {
        url: 'http://10.1.40.84:9993/getLike',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data: { ...prop, field: 'country' },
      };
    },
    {
      manual: true,
    },
  );

  const gender = useRequest(
    () => {
      return {
        url: 'http://10.1.40.84:9993/getLike',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data: { ...prop, field: 'gender' },
      };
    },
    {
      manual: true,
    },
  );
  const idType = useRequest(
    () => {
      return {
        url: 'http://10.1.40.84:9993/getLike',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data: { ...prop, field: 'idType' },
      };
    },
    {
      manual: true,
    },
  );
  const nation = useRequest(
    () => {
      return {
        url: 'http://10.1.40.84:9993/getLike',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data: { ...prop, field: 'nation' },
      };
    },
    {
      manual: true,
    },
  );

  const politicalStatus = useRequest(
    () => {
      return {
        url: 'http://10.1.40.84:9993/getLike',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data: { ...prop, field: 'politicalStatus' },
      };
    },
    {
      manual: true,
    },
  );
  const unit = useRequest(
    () => {
      return {
        url: 'http://10.1.40.84:9993/getLike',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data: { ...prop, field: 'unit' },
      };
    },
    {
      manual: true,
    },
  );
  const topEducationMajor = useRequest(
    () => {
      return {
        url: 'http://10.1.40.84:9993/getLike',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data: { ...prop, field: 'topEducationMajor' },
      };
    },
    {
      manual: true,
    },
  );
  const technicalGrade = useRequest(
    () => {
      return {
        url: 'http://10.1.40.84:9993/getLike',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data: { ...prop, field: 'technicalGrade' },
      };
    },
    {
      manual: true,
    },
  );
  const technicalName = useRequest(
    () => {
      return {
        url: 'http://10.1.40.84:9993/getLike',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data: { ...prop, field: 'technicalName' },
      };
    },
    {
      manual: true,
    },
  );
  const position = useRequest(
    () => {
      return {
        url: 'http://10.1.40.84:9993/getLike',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data: { ...prop, field: 'position' },
      };
    },
    {
      manual: true,
    },
  );

  const topDegree = useRequest(
    () => {
      return {
        url: 'http://10.1.40.84:9993/getLike',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data: { ...prop, field: 'topDegree' },
      };
    },
    {
      manual: true,
    },
  );
  const topEducation = useRequest(
    () => {
      return {
        url: 'http://10.1.40.84:9993/getLike',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data: { ...prop, field: 'topEducation' },
      };
    },
    {
      manual: true,
    },
  );

  return {
    countryType: countryType,
    country: country,
    gender: gender,
    idType: idType,
    nation: nation,
    politicalStatus: politicalStatus,
    unit: unit,
    topEducationMajor: topEducationMajor,
    technicalGrade: technicalGrade,
    technicalName: technicalName,
    position: position,
    topDegree: topDegree,
    topEducation: topEducation,
  };
}
